<?php
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
    'id' => 'subscriber-form',
    'type' => 'horizontal',
    'enableAjaxValidation' => false,
        ));
?>

<p class="help-block">Fields with <span class="required">*</span> are required.</p>

<?php echo $form->errorSummary($model); ?>

<?php $streets = Street::model()->findAll(); ?>

<div class="control-group ">
    <label for="BusStation_station_id" class="control-label">Street</label>
    <div class="controls">
        <?php
        echo CHtml::dropDownList('Street', NULL, CHtml::listData($streets, 'street_id', 'name'),
        array(
            'id' => 'street',
        'ajax' => array(
            'type' => 'POST', //request type
            'url' => CController::createUrl('station/getbyStreet'), //url to call.
    //Style: CController::createUrl('currentController/methodToCall')
            'update' => '#station')));
        ?>
        </select>
    </div>
</div>

    <?php //echo $form->textFieldRow($model,'name',array('class'=>'span5','maxlength'=>128));  ?>

    <?php echo $form->dropDownListRow($model, 'station_id', array(), array('id' => 'station')); ?>

<div class="form-actions">
    <?php
    $this->widget('bootstrap.widgets.TbButton', array(
        'buttonType' => 'submit',
        'type' => 'primary',
        'label' => $model->isNewRecord ? 'Create' : 'Save',
    ));
    ?>
</div>

<?php $this->endWidget(); ?>

<script>
    $(function() {
        $('#street').trigger('change');
    })
    
    </script>
